/**
 * 私信相关接口
 */
import request from '@/config/request'
import type { CvConversationSaveReqVO } from '@/types/message'

/**
 * 清除未读消息个数
 */
export const clearUnreadCount = (conversationId: number) => {
  return request.post({ url: '/platform/message/clearUnreadCount', params: { conversationId } })
}

/**
 * 获得最近聊天列表
 */
export const getRecentMessageList = () => {
  return request.get({ url: '/platform/message/getRecentMessageList' })
}

/**
 * 获得聊天列表
 */
export const getMessageList = (conversationId: number) => {
  return request.get({ url: '/platform/message/getMessageList', params: { conversationId } })
}

/**
 * 创建会话
 */
export const createConversation = (reqVO: CvConversationSaveReqVO) => {
  return request.post({ url: '/platform/message/createConversation', data: reqVO })
}

/**
 * 获得会话编号
 */
export const getConversationId = (userId: number, targetId: number) => {
  return request.get({ url: '/platform/message/getConversationId', params: { userId, targetId } })
}

/**
 * 判断会话是否被隐藏
 */
export const getConversationIsVisible = (conversationId: number) => {
  return request.get({
    url: '/platform/message/getConversationIsVisible',
    params: { conversationId }
  })
}

/**
 * 设置会话是否可见
 */
export const setConversationVisible = (conversationId: number, visible: boolean) => {
  return request.put({
    url: '/platform/message/setConversationVisible',
    params: { conversationId, visible }
  })
}
